﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using MyLibrary.ThreeLayer.DataAccess.QueryLanguage;

namespace MyLibrary.ThreeLayer.DataAccess.Interface
{
    public interface ISession : ITransaction, IBaseSession, IRelationSession, IConditionSession, ICloseRequire
    {

    }

    public interface IBaseSession
    {
        int Delete<T>(T o) where T : class, new();
        int Delete<T>() where T : class, new();
        T Get<T>(object keys) where T : class, new();
        int Insert<T>(T obj) where T : class, new();
        bool Load<T>(T obj) where T : class, new();
        IList<T> LoadAll<T>(T obj) where T : class, new();
        int Save<T>(T obj) where T : class, new();
        int Update<T>(T obj) where T : class, new();
    }

    public interface IRelationSession
    {
        int Delete<T>(T obj, bool deleteRef) where T : class, new();
        int DeleteRef(object obj1, object obj2);
        T GetRef<T>(object obj) where T : class, new();
        List<T> GetRefList<T>(object obj) where T : class, new();
        int SaveRef(object obj1, object obj2);
    }

    public interface IConditionSession
    {
        int Delete<T>(ConditionExpression condition) where T : class, new();
        T Get<T>(ConditionExpression condition) where T : class, new();
        IList<T> JoinQuery<T>(ConditionExpression condition) where T : class, new();
        IList<T> Query<T>(ConditionExpression condition) where T : class, new();
        IList<T> Query<T>(QueryExpression query) where T : class, new();
        DataSet QueryDataSet(params QueryExpression[] querys);
        DataTable QueryDataTable<T>(ConditionExpression query) where T : class, new();
        int Update<T>(T obj, ConditionExpression condition) where T : class, new();
        int Update<T>(T obj, ConditionExpression condition, IQueryField[] fields) where T : class, new();
    }
}
